<template>
	<view class="yingdidetail">
		<headertop title="详情" :back1="back1"></headertop>
		<up-swiper height="332" :list="list6" @change="e => currentNum = e.current" :autoplay="false"
			indicatorStyle="right: 20px">
			<template #indicator>
				<view class="indicator-num">
					<text class="indicator-num__text">{{ currentNum + 1 }}/{{ list6.length }}</text>
				</view>
			</template>
		</up-swiper>
		<view class="yindifeibox">
			<image src="https://39gongli.oss-cn-beijing.aliyuncs.com/static/Group 11423@2x.png" class="yindifeibox_bakc"
				mode=""></image>
			<view class="btnyidi">
				租赁费
			</view>
			<view class="jiageline">
				<view class="jiage">
					￥{{contentobj.price}}
					<span style="margin-left: 36rpx;" class="jiag1">
						押金：￥{{contentobj.deposit}}
					</span>
				</view>

				<!-- 	<view class="jiag1">
					押金：￥{{contentobj.deposit}}
				</view> -->
			</view>
		</view>
		<view class="bottomcontent">
			<view class="centerinfo">
				<view class="topline">
					<view class="title">
						{{contentobj.title}}
					</view>
					<view class="icons">
						<!-- 		<image
							:src="contentobj.collect==1?'https://39gongli.oss-cn-beijing.aliyuncs.com/static/微信图片_20250513100026.png':'https://39gongli.oss-cn-beijing.aliyuncs.com/static/Frame@2x(35).png'"
							class="icon1" mode="" @click="collectfun"></image> -->
						<button class="righttex" open-type="share" @chooseavatar="onChooseAvatar">
							<image src="https://39gongli.oss-cn-beijing.aliyuncs.com/static/Frame@2x(36).png"
								class="rightteximg" mode="">
							</image>
						</button>

					</view>
				</view>
				<view class="text1">
					{{contentobj.detail}}
				</view>

			</view>

			<view class="jiange" style="margin-top: 28rpx;">

			</view>
			<view class="xqnr">
				<view class="titleline">
					<view class="bqt">

					</view>
					<span>详情</span>
				</view>
				<view class="content">
					<up-parse :content="contentobj.content"></up-parse>
				</view>
			</view>


		</view>
		<view class="" style="height: 190rpx;">
		</view>
		<view class="fixedbox">
			<view class="btn" @click="gopage">
				立即租赁
			</view>
		</view>
		<userlogin ref="denglu" @updata="getuser"></userlogin>
	</view>
</template>

<script setup>
	import userlogin from '@/components/getuser/getuser.vue'
	import headertop from '@/components/header.vue'
	import {
		reactive,
		ref
	} from 'vue';
	import {
		onPageScroll,
		onLoad
	} from "@dcloudio/uni-app";
	import {
		leasefile
	} from '@/api/lease.js'
	import {
		collect
	} from '@/api/Campposition.js'
	const currentNum = ref(0)
	const denglu = ref(null)
	const contentobj = ref({})
	const list6 = ref([

	]);
	const content = ref(`
		<p>这是详情内容1231231231</p>  
	`);
	const back1 = ref('')
	const id = ref('')
	onLoad((opt) => {
		id.value = opt.id
		init(opt.id)
		wx.showShareMenu({
			withShareTicket: true,
			menus: ["shareAppMessage", "shareTimeline"]
		})
	})

	function onShareAppMessage() {
		return {
			title: '39公里小程序', //分享的名称
			path: '/sub_lease/lease/yingdidetail1?id=' + id.value
			//页面的路径
		}
	}
	//分享到朋友圈
	function onShareTimeline() {
		return {
			title: '39公里小程序',
			path: '/sub_lease/lease/yingdidetail1?id=' + id.value
		}
	}

	function getuser() {
		init(id.value)
	}
	onPageScroll((e) => {
		console.log(e, 'eeeeeeeeeeeeeeeeeeeee')
		if (e.scrollTop > 100) {
			back1.value = 'rgba(0,0,0,0.32)'
		} else {
			back1.value = ''
		}
	})

	async function init(id) {
		const res = await leasefile({
			id
		})
		if (res.data.code == 1) {
			contentobj.value = res.data.data
			var looplist = res.data.data.images.split(',')
			list6.value = looplist.map(item => item)
		}
	}
	async function collectfun() {
		if (!uni.getStorageSync('token')) {
			denglu.value.DengLu()
			return
		}
		const res = await collect({
			gid: contentobj.value.id,
			type: 2
		})
		if (res.data.code == 1) {
			if (contentobj.value.collect == 1) {
				contentobj.value.collect = 0
				uni.showToast({
					title: '取消成功'
				})
			} else {
				contentobj.value.collect = 1
				uni.showToast({
					title: '收藏成功'
				})
			}

		} else {
			uni.showToast({
				title: res.data.msg
			})
		}
	}

	function gopage() {
		if (!uni.getStorageSync('token')) {
			denglu.value.DengLu()
			return
		}
		uni.navigateTo({
			url: '/sub_lease/lease/leaseinfo?id=' + id.value
		})
	}
</script>

<style lang="scss">
	.fixedbox {
		width: 100%;
		overflow: hidden;
		height: 184rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -4rpx 4rpx 0rpx rgba(0, 0, 0, 0.08);
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		position: fixed;
		bottom: 0%;

		.btn {
			width: 686rpx;
			height: 88rpx;
			background: #7EBC79;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			text-align: center;
			line-height: 88rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 88rpx;
			margin: auto;
			margin-top: 22rpx;
		}
	}

	.rightcontent .qinr:nth-child(3n) {
		margin-right: 0rpx !important;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 750rpx;
		margin-left: 32rpx;
		margin-top: 22rpx;

		.scroll-view-item_H {
			display: inline-block;
			width: 276rpx;
			height: 182rpx;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			overflow: hidden;
			margin-right: 16rpx;

			image {
				width: 276rpx;
				height: 182rpx;
			}
		}
	}


	.yingdidetail {
		width: 100%;
		overflow: hidden;

		.bottomcontent {
			width: 100%;
			background: #FFFFFF;
			border-radius: 36rpx 36rpx 0rpx 0rpx;
			margin-top: -20rpx;
			overflow: hidden;

			.xqnr {
				width: 686rpx;
				margin: auto;
				margin-top: 24rpx;
				overflow: hidden;

				.titleline {
					width: 100%;
					display: flex;
					align-items: center;
					font-weight: bold;
					font-size: 32rpx;
					color: #1D2129;

					.bqt {
						width: 6rpx;
						height: 36rpx;
						background: #7EBC79;
						border-radius: 0rpx 24rpx 24rpx 0rpx;
						margin-right: 12rpx;
					}
				}

				.content {
					width: 100%;
					overflow: hidden;
					margin-top: 24rpx;

				}
			}

			.jiange {
				width: 100%;
				height: 28rpx;
				background: #F7F8FA;
			}

			.centerinfo {
				width: 686rpx;
				margin: auto;
				margin-top: 26rpx;
				overflow: hidden;

				.text1 {
					width: 100%;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #868686;
					margin-top: 26rpx;
				}

				.topline {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.icons {
						display: flex;
						align-items: center;

						.icon1 {
							width: 40rpx;
							height: 38.34rpx;
							margin-right: 38rpx;
						}

						.righttex {
							width: 36rpx;
							height: 36rpx;
							position: relative;
							display: flex;
							border: none !important;
							align-items: center;
							overflow: auto !important;
							// background: $btn !important;
							background-color: none !important;
							background-size: 100% 138% !important;
							padding-left: 0 !important;
							padding-right: 0 !important;
							margin-left: 0rpx !important;
							-webkit-tap-highlight-color: none !important;
							margin-right: 0 !important;
							overflow: hidden !important;

							&:after {
								border: none;
								background-color: none !important;
							}

							.rightteximg {
								width: 36rpx;
								height: 36rpx;
								position: absolute;
							}

						}

					}

					.title {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 44rpx;
						color: #1D2129;
					}
				}
			}

			.line1 {
				width: 686rpx;
				height: 90rpx;
				position: relative;
				display: flex;
				align-items: center;
				margin: auto;
				margin-top: 32rpx;

				.img1 {
					width: 68rpx;
					height: 68rpx;
					margin-left: 16rpx;
					z-index: 999;
				}

				.lijikait {
					width: 156rpx;
					height: 86rpx;
					background-color: #A4E197;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 86rpx;
					z-index: 999;
					margin-left: 132rpx;
				}

				.text {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #64D34D;
					z-index: 999;
					white-space: normal;
					margin-left: 20rpx;
				}

				.line1back {
					position: absolute;
					width: 686rpx;
					height: 90rpx;
				}
			}
		}

		.yindifeibox {
			width: 100%;
			height: 178rpx;
			position: relative;
			overflow: hidden;

			&_bakc {
				width: 100%;
				height: 178rpx;
				position: absolute;
				z-index: -1;
			}

			.btnyidi {
				width: 112rpx;
				height: 38rpx;
				background: #FFFFFF;
				border-radius: 6rpx 6rpx 6rpx 6rpx;
				text-align: center;
				line-height: 38rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #48863B;
				margin-left: 32rpx;
				margin-top: 24rpx;
			}

			.jiageline {
				margin-top: 16rpx;
				display: flex;
				align-items: center;
				margin-left: 32rpx;

				.jiage {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 44rpx;
					color: #FFFFFF;
				}

				.jiag1 {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #FFFFFF;
					margin-left: 36rpx;
				}
			}
		}

		.indicator-num {
			padding: 2px 0;
			background-color: rgba(0, 0, 0, 0.35);
			border-radius: 100px;
			width: 35px;
			@include flex;
			justify-content: center;

			&__text {
				color: #FFFFFF;
				font-size: 12px;
			}
		}
	}
</style>